package operator;

/**
 * @author ChenYongHao
 * @date 2023/4/27 9:12
 * @desc 运算符
 */

import java.util.Scanner;

/**
 * 算术运算符
 * 自增和自减
 * 赋值运算符
 * 关系运算符
 * 逻辑运算符
 * 三元运算符
 */
public class OperatorDemo {
    public static void main(String[] args) {
        int i=10;
       // System.out.println("i = " + --i);
        // System.out.println("i = " + ++i);
        System.out.println(i++);
        System.out.println(i--);
        System.out.println("i = " + i);

//        short s = 10;
//        s = s + 10;  //此行代码报错，因为运算中s提升为int类型，运算结果int赋值给short可能损失精度
//
//        short s = 10;
//        s += 10;     //此行代码正确，隐含了强制类型转换，相当于 s = (short)(s + 10);
        //三元运算符
        int a = 10;
        int b = 20;
        int max = a > b ? a : b;
        System.out.println("max = " + max);

        //数据输入
        Scanner sc = new Scanner(System.in);
        int test = sc.nextInt();
        System.err.println(test);


    }
}
